package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.ConfigDynamicSqlSupport.*;

import cc.prayol.permission.entity.auth.Config;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface ConfigMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    BasicColumn[] selectList = BasicColumn.columnList(configId, configName, configKey, configValue, configType, createBy, createTime, updateBy, updateTime, remark);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<Config> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("ConfigResult")
    Optional<Config> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="ConfigResult", value = {
        @Result(column="config_id", property="configId", jdbcType=JdbcType.INTEGER),
        @Result(column="config_name", property="configName", jdbcType=JdbcType.VARCHAR),
        @Result(column="config_key", property="configKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="config_value", property="configValue", jdbcType=JdbcType.VARCHAR),
        @Result(column="config_type", property="configType", jdbcType=JdbcType.CHAR),
        @Result(column="create_by", property="createBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_by", property="updateBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<Config> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, config, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, config, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    default int insert(Config record) {
        return MyBatis3Utils.insert(this::insert, record, config, c ->
            c.map(configId).toProperty("configId")
            .map(configName).toProperty("configName")
            .map(configKey).toProperty("configKey")
            .map(configValue).toProperty("configValue")
            .map(configType).toProperty("configType")
            .map(createBy).toProperty("createBy")
            .map(createTime).toProperty("createTime")
            .map(updateBy).toProperty("updateBy")
            .map(updateTime).toProperty("updateTime")
            .map(remark).toProperty("remark")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    default int insertSelective(Config record) {
        return MyBatis3Utils.insert(this::insert, record, config, c ->
            c.map(configId).toPropertyWhenPresent("configId", record::getConfigId)
            .map(configName).toPropertyWhenPresent("configName", record::getConfigName)
            .map(configKey).toPropertyWhenPresent("configKey", record::getConfigKey)
            .map(configValue).toPropertyWhenPresent("configValue", record::getConfigValue)
            .map(configType).toPropertyWhenPresent("configType", record::getConfigType)
            .map(createBy).toPropertyWhenPresent("createBy", record::getCreateBy)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(updateBy).toPropertyWhenPresent("updateBy", record::getUpdateBy)
            .map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
            .map(remark).toPropertyWhenPresent("remark", record::getRemark)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    default Optional<Config> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, config, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.582+08:00", comments="Source Table: sys_config")
    default List<Config> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, config, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.583+08:00", comments="Source Table: sys_config")
    default List<Config> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, config, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.583+08:00", comments="Source Table: sys_config")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, config, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.583+08:00", comments="Source Table: sys_config")
    static UpdateDSL<UpdateModel> updateAllColumns(Config record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(configId).equalTo(record::getConfigId)
                .set(configName).equalTo(record::getConfigName)
                .set(configKey).equalTo(record::getConfigKey)
                .set(configValue).equalTo(record::getConfigValue)
                .set(configType).equalTo(record::getConfigType)
                .set(createBy).equalTo(record::getCreateBy)
                .set(createTime).equalTo(record::getCreateTime)
                .set(updateBy).equalTo(record::getUpdateBy)
                .set(updateTime).equalTo(record::getUpdateTime)
                .set(remark).equalTo(record::getRemark);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.583+08:00", comments="Source Table: sys_config")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Config record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(configId).equalToWhenPresent(record::getConfigId)
                .set(configName).equalToWhenPresent(record::getConfigName)
                .set(configKey).equalToWhenPresent(record::getConfigKey)
                .set(configValue).equalToWhenPresent(record::getConfigValue)
                .set(configType).equalToWhenPresent(record::getConfigType)
                .set(createBy).equalToWhenPresent(record::getCreateBy)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(updateBy).equalToWhenPresent(record::getUpdateBy)
                .set(updateTime).equalToWhenPresent(record::getUpdateTime)
                .set(remark).equalToWhenPresent(record::getRemark);
    }
}